<div class="admin">
    <form method="post" name="myform" id="myform">
        <div class="panel admin-panel">
            <div class="panel-head"><strong>添加满减送</strong></div>
            <div class="padding border-bottom">
                <div class="bg-back radius padding">
                    <h4>说明：</h4>
                    <p class="text-indent">满即送活动包括店铺所有商品，活动时间不能和已有活动重叠</p>
                    <p class="text-indent">每个满即送活动最多可以设置3个价格级别，点击新增级别按钮可以增加新的级别，价格级别应该由低到高</p>
                </div>
            </div>
            <table class="table table-hover">
                <tr>
                    <td width='160px'><span class="c-red">*</span>活动标题：</td>
                    <td width='*'><input type="text" class="input input_big" value="{$re['mansong_name']}" placeholder="" id="" name="title"></td>
                    <td width='*'></td>
                </tr>
                <tr>
                    <td><span class="c-red">*</span>开始日期：</td>
                    <td><input type="text" class="input input_small" readonly="readonly" value="{$re['start_time']|date='Y-m-d',###}" id="query_start_time" name="start_time"><em class="add-on"><i class="icon-calendar"></i></em></td>
                    <td></td>
                </tr>
                <tr>
                    <td><span class="c-red">*</span>结束日期：</td>
                    <td><input type="text" class="input input_small" readonly="readonly" value="{$re['end_time']|date='Y-m-d',###}" id="query_end_time" name="end_time"><em class="add-on"><i class="icon-calendar"></i></em></td>
                    <td></td>
                </tr>
                <tr>
                    <td><span class="c-red">*</span>规则：</td>
                    <td>
                        <div class="attr">
                            <foreach item='v' name="re['pMansong']">
                                <div class="ncsc-mansong-rule">
                                    <span >单笔订单满&nbsp;<input name="mansong_price[]" class="inputL input_smallL" type="text" value="{$v['price']}"><em class="add-on">元</em>，</span>
                                    <span>立减现金&nbsp;<input name="mansong_discount[]" class="inputL input_smallL" type="text" value="{$v['discount']}"><em class="add-on">元</em></span>
                                </div>
                            </foreach>
                        </div>
                        <span id="addattr" class="button bg-blue"><i class="icon-plus"></i> 添加规则</span>
                        <span id="reduceattr" class="button bg-blue"><i class="icon-minus"></i> 减少规则</span>
                    </td>
                    <td></td>
                </tr>
                <tr>
                    <td><span class="c-red">*</span>备注：</td>
                    <td><textarea name="remark" cols="" rows="5" class="input input_big"  placeholder="说点什么...最少输入10个字符" datatype="*10-100" nullmsg="备注不能为空！" onKeyUp="textarealength(this, 200)">{$re['remark']}</textarea></td>
                    <td></td>
                </tr>   
            </table>
            <div class="panel-foot text-center">
                <div class="form-button">
                    <input name="mansong_id" value="{$re['mansong_id']}" type="hidden" />
                    <input class="button bg-main" type="submit" value="确认保存">
                    <button class="button bg" type="reset">取消</button>
                </div>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    $("#myform").Validform({
        tiptype: 3,
        showAllError:true,
    });
    
    $('#myform').layer({
    });

    $('#query_start_time').duxTime({
        timepicker: false,
        minDate: 0,
        format:"Y-m-d"
    });
    $('#query_end_time').duxTime({
        timepicker: false,
        minDate: 0,
        format:"Y-m-d"
    });

    var htmla = '<div class="ncsc-mansong-rule"><span >单笔订单满&nbsp;<input name="mansong_price[]" class="inputL input_smallL" type="text"><em class="add-on">元</em>，</span><span>立减现金&nbsp;<input name="mansong_discount[]" class="inputL input_smallL" type="text"><em class="add-on">元</em></span></div>';
    $("#addattr").click(function () {
        var num = $(".ncsc-mansong-rule").length;
        if (num <= 4) {
            $(".attr").append(htmla);
        } else {
            layer.msg('一次性优惠最多添加五个！！！');
        }
    });
    //减少商品属性  规格
    $("#reduceattr").click(function () {
        var num = $(".ncsc-mansong-rule").length;
        if (num != 1) {
            $(".attr div:last-child").remove();
        } else {
            layer.msg('优惠规则至少一个！！！');
        }
    });
</script>